<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>主界面</title>
    <script type="text/javascript" src="/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/easyui/easyloader.js"></script>
    <link rel="stylesheet" type="text/css" href="/easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css"  href="/easyui/themes/default/easyui.css">
</head>
<body >
<div class="easyui-panel" title=""  data-options="border:true">


    <table id="dg" class="easyui-datagrid" title="库存单元列表"
           data-options="singleSelect:true,method:'get',url:'wareSkuList' ,toolbar:'#tb'">
        <thead>
        <tr>
            <th data-options="field:'id'" width="5%">id </th>
            <th data-options="field:'stockName'" width="30%">库存单元名称</th>
            <th data-options="field:'stock'" width="10%">实际库存数量</th>
            <th data-options="field:'stockLocked'" width="10%">锁定库存数量</th>
            <th data-options="field:'skuId'" width="10%">外部skuId </th>
            <th data-options="field:'warehouseName'" width="20%">仓库</th>
          </tr>
        </thead>
    </table>
    <div id="tb" style="padding:5px;height:auto">
        <div style="margin-bottom:5px">
            <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="addWareSku()">添加</a>
            <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editWareSku()">编辑</a>
            <a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true">删除</a>
        </div>
        <div>



        </div>
    </div>
</div>

<div id="dlg" class="easyui-dialog" title="库存单元" style="width:260px;height:350px;"
    closed="true"  data-options="iconCls:'icon-save',resizable:true,modal:false" buttons="#bb" >

    <form id="wareSkuForm">
        <br/>
        <label>库存单元名称:</label><br/>
        <div style=" text-align: center"> <input  id="stockName" name="stockName" class="easyui-textbox" data-options="" style="left:40px;width:200px"/></div>
        <br/>
        <label>库存数量:</label><br/>
        <div style=" text-align: center"> <input  id="stock" name="stockName" class="easyui-textbox" data-options="" style="width:200px"/></div>
        <br/>
        <label>外部skuId:</label><br/>
            <div style=" text-align: center"> <input  id="skuId" name="skuId" class="easyui-textbox" data-options="" style="width:200px"/></div>
        <br/>
        <label>仓库:</label><br/>
                <div style=" text-align: center"><select name="warehouse" id="warehouseId"  class="easyui-combobox" data-options="valueField:'id',textField:'name',method:'get',url:'wareInfoList'" style="width:200px">  </select></div>


    </form>

</div>

<div id="bb">
    <a href="#" class="easyui-linkbutton" onclick="saveWareSku()">保存</a>
    <a href="#" class="easyui-linkbutton">关闭</a>
</div>

</body>
<script language="javascript">
    /*<![CDATA[*/
    function saveWareSku(){
        var formJson ={} ;
        //把表格中的数据循环组合成json
        formJson['warehouseId']=$('#warehouseId').combobox("getValue");
        formJson["stock"]=$("#stock").val();
        formJson["stockName"]=$("#stockName").val();
        formJson["skuId"]=$("#skuId").val();

        //ajax 保存到后台
        $.post("saveWareSku",formJson,function(data){
            $("#dlg").dialog("close");
            $("#dg").datagrid("reload");
        });
    }




    function addWareSku(){

        //弹出框
        $("#dlg").dialog("open");
        //进系统前先清空
        $("#stock").textbox('clear');
        $("#stockName").textbox('clear');
        $("#skuId").textbox('clear');
        $('#warehouseId').combobox('reset');

    }








    /*]]>*/
</script>

</html>